package com.sky.mapper;

import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.globalAnnotation.AutoFill;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;


import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    /**
     * 添加菜品
     * @param dish
     */

    @AutoFill(OperationType.INSERT)
    void insert(Dish dish);

    List<DishVO> pageQuery(DishPageQueryDTO pageQueryDTO);

    @AutoFill(OperationType.UPDATE)
    @Update("update dish set status=#{status},create_time=#{createTime},update_time=#{updateTime},create_user=#{createUser},update_user=#{updateUser} " +
            "where id=#{id}")
    void updateStatus(Dish dish);



    DishVO getDishById(Long id);

    @Select("select * from dish where category_id=#{categoryId}")
    List<Dish> getDishListByCategoryId(Long categoryId);

    @AutoFill(OperationType.UPDATE)
    void updateDish(Dish dish);

    List<Dish> getDishByStatus(List<Long> ids);

    void deleteById(List<Long> ids);

    List<Dish> getDishByStatusToO(List<Long> ids);

    List<Dish> getDishStatus(Long id);

    @Select("select * from dish where category_id=#{categoryId}")
    List<Dish> list(Dish dish);

    DishVO getDish(Long dishId);

    @Select("select count(*) from dish where status=#{status}")
    Integer countByMap(Map map);


//    List<Dish> getDishByIdList(List<Long> dishId);


    //List<Dish> getDishById(Integer );
}
